package edu.njust.cma.mapper;

import edu.njust.cma.DTO.SubTaskForLab;
import edu.njust.cma.pojo.SubtaskSimulation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SubTaskSimulationMapper {

    @Select("select * from subtasks_simulation where task_id=#{taskId}")
    SubtaskSimulation getSubtaskSimulation(Integer taskId);

    @Insert("insert into subtasks_simulation(task_id, user_id) values(#{taskId}, #{userId})")
    void insert(SubtaskSimulation subtaskSimulation);


    @Select("select * from subtasks_simulation where user_id=#{userId}")
    List<SubtaskSimulation> getSubtaskSimulationByUserId(Integer userId);

    //TODO 提交相关文件用的我默认主任分解完就已经有相应的条目了,我只需要找到修改就行
    @Update("update subtasks_simulation set report_pdf_url=#{reportPdfUrl}, " +
            "original_record_pdf_url=#{originalRecordPdfUrl} where task_id=#{taskId}")
    void update(int taskId, String reportPdfUrl, String originalRecordPdfUrl);

    @Update("update subtasks_simulation set status=#{status} where id=#{id}")
    void updateStatus(Integer id, int status);

    @Select("select status from subtasks_simulation where task_id=#{taskId}")
    int getStatus(Integer taskId);

    @Select("select * from subtasks_simulation where user_id=#{userId}")
    List<SubtaskSimulation> getSimulateTaskByUserId(int userId);

    @Select("select * from subtasks_simulation where user_id=#{userId}")
    List<SubtaskSimulation> getSimulationTaskByUserId(int userId);

    @Select("select * from subtasks_simulation where task_id=#{taskId}")
    SubtaskSimulation getSubtaskSimulationByTaskId(int taskId);

    @Update("update subtasks_simulation set report_pdf_url=#{reportPdfUrl}, " +
            "original_record_pdf_url=#{originalRecordPdfUrl} where id=#{id}")
    void updateUrlById(int id, String reportPdfUrl, String originalRecordPdfUrl);

    @Update("update subtasks_simulation set Submission_time=#{nowTime} where id=#{id}")
    void updateTimeById(int id, String nowTime);
}
